{template 'common/header'}
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWebUrl('Info');}">信息管理</a></li>
</ul>
<div class="main">
	
	<!-- 添加信息 -->
    <div>
    	<form class="form-horizontal form" action="" method="post">
    		<input type="hidden" name="token" value="{$_W['token']}" />
	        <table class="table table-hover">
	            <thead class="navbar-inner">
	                <tr>
	                    <th>名称</th>
	                    <th width="8%">电话</th>
	                    <th width="8%">区域</th>
	                    <th width="8%">分类</th>
	                    <th>地址</th>
	                    <th width="5%">认证</th>
	                    <th>位置</th>
	                    <th width="8%"></th>
	                </tr>
	            </thead>
	            <tbody>
	            	<tr>
	            		<td><input type="text" name="data[name]" class="form-control"></td>
	            		<td><input type="text" name="data[mobile]" class="form-control"></td>
	            		<td>
	            			<select class="form-control" name="data[zone]">
	            				{loop $zoneparents $key $parent}
		                        	<option value="{$parent['id']}" {if $row['parent_id'] == $parent['id']} selected {/if}>{$parent['name']}</option>
		                        	{loop $parent['sub'] $sub}
			                      	<option value="{$sub['id']}" {if $row['parent_id'] == $sub['id']} selected {/if}>&nbsp;&nbsp;|—{$sub['name']}</option>
			                    	{/loop}
                    			{/loop}
	            			</select>
	            		</td>
	            		
		            	<td>
	            			<select class="form-control" name="data[category]">
	            				{loop $parents $key $parent}
		                        	<option value="{$parent['id']}" {if $row['parent_id'] == $parent['id']} selected {/if}>{$parent['name']}</option>
		                        	{loop $parent['sub'] $sub}
			                      	<option value="{$sub['id']}" {if $row['parent_id'] == $sub['id']} selected {/if}>&nbsp;&nbsp;|—{$sub['name']}</option>
			                    	{/loop}
                    			{/loop}
	            			</select>
	            		</td>
	            		
	            		<td><input type="text" name="data[address]" class="form-control"></td>
		            	<td>
	            			<select class="form-control" name="data[isauth]">
	            				<option value="0">否</option>
	            				<option value="1">是</option>
	            			</select>
	            		</td>
	            		
	            		<td>
	            			{php echo tpl_form_field_coordinate('data[coordinate]');}
	            		</td>
	            		<td>
	            			<!-- <button id="saveinfo" class="btn btn-primary" name="button">保存</button>-->
	            			<input type="submit" class="btn btn-primary" name="save_info" value="保存"> 
	            		</td>
	            	</tr>
	            </tbody>
	        </table>
        </form>
    </div>
    
    <!-- 信息列表 -->
    <div>
    	<table class="table table-hover">
           <tbody>
           {loop $lists $info}
           	<tr>
           		<td>{$info['name']}</td>
           		<td>{$info['mobile']}</td>
           		<td>{$info['zone_name']}</td>
            	<td>{$info['cate_name']}</td>
           		<td>{$info['address']}</td>
            	<td  width="3%">
            		{if $info['isauth']}
            			<span class="label label-success">是</span>
            		{else}
            			<span class="label label-warning">否</span>
            		{/if}
            	</td>
            	<!-- <td width="8%">
	            	{php echo tpl_form_field_coordinate('data[aa]');}
	          	</td> -->
           		<td>{$info['dateline']}</td>
           		<td>
           			<a class="btn btn-primary" href="{php echo $this->createWebUrl('EditInfo', array('infoid' => $info['id']));}">编辑</a>
           			<a class="btn btn-danger" href="javascript:void(0)" onclick="delete_info({$info[id]});">删除</a>
           		</td>
           	</tr>
           	{/loop}
           </tbody>
       </table>
       {$pager}
    </div>
</div>
    
<script>
	function delete_info(infoid){
		$.post(
			'{php echo $this->createWebUrl("DeleteInfoAjax");}',
			{"infoid":infoid},
			function (data){
				location.reload();
			}
		);
		
	}
	//AJAX提交表单
/* 	$("form").submit(function(){
		alert('aax');

		$.ajax({
			type: "POST",
			url : "{php echo $this->createWebUrl('AddInfoAjax');}",
			data : $("form").serialize(),
			error :function(data, textStatus){
				alert(data);
				alert(textStatus);
				return false;
			},
			success :function(data){
				alert('B');
				return false;
			}
		
		});
	}); */
</script>
{template 'common/footer'}